import 'package:flutter/widgets.dart';

import 'inherited_test_model.dart';

class InheritedContext extends InheritedWidget {
  //数据
  final InheritedTestModel inheritedModel;

  //点击+号的方法
  final Function() increment;

  //点击-号的方法
  final Function() reduce;

  InheritedContext(this.inheritedModel, this.increment, this.reduce, Widget child) : super(child: child);

  static InheritedContext of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<InheritedContext>();
  }

  @override
  bool updateShouldNotify(InheritedContext oldWidget) {
    return inheritedModel != oldWidget.inheritedModel;
  }
}
